package View;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JComponent;
import javax.swing.JFrame;

/**
 * 
 * @author Emily Curtin
 * Constructs non-animated graphical icons
 * for the different species in the game. Has ability
 * to draw "selector bars" around an icon if it is selected.
 */

public class RaceIcon extends JComponent implements Selectable
{
	
	BufferedImage race;
	BufferedImage selectorBars;
	private boolean selected;
	
	/**
	 * Constructs the images based on file parameters. Catches
	 * a FileNotFound exception which is also caught in RaceChooser
	 * where Files are initialized.
	 * @param raceFileName
	 * @param selectorBarsFileName
	 */
	public RaceIcon(String raceFileName, String selectorBarsFileName)
	{
		try
		{
			race = ImageIO.read(new File(raceFileName));
			selectorBars = ImageIO.read(new File(selectorBarsFileName));
			
		}
		catch(IOException e) 
		{
			System.out.println("Image file not found");
		}
	}
	
	/**
	 * Overrides the paintComponent method of JComponent.
	 * Draws the selector bars around the image if isSelected()
	 * This method is called automatically by the container, it does
	 * not need to be called directly, from what I understand.
	 */
	@Override
	public void paintComponent(Graphics g)
	{
		g.drawImage( race, 10, 10, null );
		
		if (selected)
		{
			//g.drawImage( selectorBars, 0, 0, null );
		}
	}

	/**
	 * Getter for isSelected
	 */
	public boolean isSelected()
	{
		return selected;
	}
	
	/**
	 * Setter for isSelected
	 */
	public void setSelected( boolean b)
	{
		selected = b;
	}
	
}



